home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / MCA_DMA.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  127 lines

  1. #ifndef MCA_DMA_H
  2. #define MCA_DMA_H
  3.  
  4. #include <asm/io.h>
  5. #include <linux/ioport.h>
  6.  
  7. /*
  8.  * Microchannel specific DMA stuff.  DMA on an MCA machine is fairly similar to
  9.  *   standard PC dma, but it certainly has its quirks.  DMA register addresses
  10.  *   are in a different place and there are some added functions.  Most of this
  11.  *   should be pretty obvious on inspection.  Note that the user must divide
  12.  *   count by 2 when using 16-bit dma; that is not handled by these functions.
  13.  *
  14.  * Ramen Noodles are yummy.
  15.  * 
  16.  *  1998 Tymm Twillman <tymm@computer.org>  
  17.  */
  18.  
  19. /*
  20.  * Registers that are used by the DMA controller; FN is the function register 
  21.  *   (tell the controller what to do) and EXE is the execution register (how
  22.  *   to do it)
  23.  */
  24.  
  25. #define MCA_DMA_REG_FN  0x18
  26. #define MCA_DMA_REG_EXE 0x1A 
  27.  
  28. /*
  29.  * Functions that the DMA controller can do
  30.  */
  31.  
  32. #define MCA_DMA_FN_SET_IO       0x00
  33. #define MCA_DMA_FN_SET_ADDR     0x20
  34. #define MCA_DMA_FN_GET_ADDR     0x30
  35. #define MCA_DMA_FN_SET_COUNT    0x40
  36. #define MCA_DMA_FN_GET_COUNT    0x50
  37. #define MCA_DMA_FN_GET_STATUS   0x60
  38. #define MCA_DMA_FN_SET_MODE     0x70
  39. #define MCA_DMA_FN_SET_ARBUS    0x80
  40. #define MCA_DMA_FN_MASK         0x90
  41. #define MCA_DMA_FN_RESET_MASK   0xA0
  42. #define MCA_DMA_FN_MASTER_CLEAR 0xD0
  43.  
  44. /*
  45.  * Modes (used by setting MCA_DMA_FN_MODE in the function register)
  46.  * 
  47.  * Note that the MODE_READ is read from memory (write to device), and
  48.  *   MODE_WRITE is vice-versa.  
  49.  */
  50.  
  51. #define MCA_DMA_MODE_XFER  0x04  /* read by default */
  52. #define MCA_DMA_MODE_READ  0x04  /* same as XFER */
  53. #define MCA_DMA_MODE_WRITE 0x08  /* OR with MODE_XFER to use */
  54. #define MCA_DMA_MODE_IO    0x01  /* DMA from IO register */
  55. #define MCA_DMA_MODE_16    0x40  /* 16 bit xfers */
  56.  
  57.  
  58.  
  59. static __inline__ void mca_enable_dma(unsigned int dmanr)
  60. {
  61.     outb(MCA_DMA_FN_RESET_MASK | dmanr, MCA_DMA_REG_FN);
  62. }
  63.  
  64. static __inline__ void mca_disable_dma(unsigned int dmanr)
  65. {
  66.     outb(MCA_DMA_FN_MASK | dmanr, MCA_DMA_REG_FN);
  67. }
  68.  
  69. static __inline__ void mca_set_dma_addr(unsigned int dmanr, unsigned int a)
  70. {
  71.     outb(MCA_DMA_FN_SET_ADDR | dmanr, MCA_DMA_REG_FN);
  72.     outb(a & 0xff, MCA_DMA_REG_EXE);
  73.     outb((a >> 8) & 0xff, MCA_DMA_REG_EXE);
  74.     outb((a >> 16) & 0xff, MCA_DMA_REG_EXE);
  75. }
  76.  
  77. static __inline__ unsigned int mca_get_dma_addr(unsigned int dmanr)
  78. {
  79.     unsigned int addr;
  80.  
  81.     outb(MCA_DMA_FN_GET_ADDR | dmanr, MCA_DMA_REG_FN);
  82.     addr = inb(MCA_DMA_REG_EXE);
  83.     addr |= inb(MCA_DMA_REG_EXE) << 8;
  84.     addr |= inb(MCA_DMA_REG_EXE) << 16;  
  85.  
  86.     return addr;
  87. }
  88.  
  89. static __inline__ void mca_set_dma_count(unsigned int dmanr, unsigned int count)
  90. {
  91.     count--;  /* transfers one more than count -- correct for this */
  92.  
  93.     outb(MCA_DMA_FN_SET_COUNT | dmanr, MCA_DMA_REG_FN);
  94.     outb(count & 0xff, MCA_DMA_REG_EXE);
  95.     outb((count >> 8) & 0xff, MCA_DMA_REG_EXE);
  96. }
  97.  
  98. static __inline__ unsigned int mca_get_dma_residue(unsigned int dmanr)
  99. {
  100.     unsigned short count;
  101.  
  102.     outb(MCA_DMA_FN_GET_COUNT | dmanr, MCA_DMA_REG_FN);
  103.     count = 1 + inb(MCA_DMA_REG_EXE);
  104.     count += inb(MCA_DMA_REG_EXE) << 8;
  105.  
  106.     return count;
  107. }
  108.  
  109. static __inline__ void mca_set_dma_io(unsigned int dmanr, unsigned int io_addr)
  110. {
  111.     /*
  112.      * DMA from a port address -- set the io address
  113.      */
  114.     
  115.     outb(MCA_DMA_FN_SET_IO | dmanr, MCA_DMA_REG_FN);
  116.     outb(io_addr & 0xff, MCA_DMA_REG_EXE);
  117.     outb((io_addr >>  8) & 0xff, MCA_DMA_REG_EXE);
  118. }
  119.  
  120. static __inline__ void mca_set_dma_mode(unsigned int dmanr, unsigned int mode)
  121. {
  122.     outb(MCA_DMA_FN_SET_MODE | dmanr, MCA_DMA_REG_FN);
  123.     outb(mode, MCA_DMA_REG_EXE);
  124. }
  125.  
  126. #endif MCA_DMA_H
  127.